package eg9_15;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class WindowEventDemo extends JFrame {
    private JTextField textField;
    public WindowEventDemo(){
        textField = new JTextField();
        textField.setColumns(20);
        this.add(textField);
        this.setLayout(new FlowLayout());
        this.addWindowFocusListener(new WindowAdapter() {
            public void windowActivated(WindowEvent e){
                setTitle("我被激活");
            }
            public void windowOpened(WindowEvent e){
                textField.setText("窗口被打开");
            }
            public void windowDeiconified(WindowEvent e){
                textField.setText("最小化恢复");
            }
            public void windowClosing(WindowEvent e){
                System.exit(0);
            }
        });
        this.setBounds(100,100,600,360);
        this.setVisible(true);
    }
}
